package com.pattern.demo.protogenesis;

/**
 * @ClassName: CurrentConditionsDisplay   当前时间温度、湿度看板
 * @Description:
 * @Date: 2020/8/27 15:15
 * @Author: Song JinGen
 */
public class CurrentConditionsDisplay implements Observer, DisplayElement {
    private Subject weatherData;
    /**
     *  温度
     */
    private float temperature;

    /**
     * 湿度
     */
    private float humidity;

    private String msg;

    public CurrentConditionsDisplay(Subject weatherData){
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    /**
     * 天气展示看板
     */
    public void display() {
        System.out.println("当前时间温度情况：【 温度 ："+temperature+"F ；湿度："+humidity+"% ; 详细信息："+msg+"】");
    }

    /**
     * 实时更新天气
     * @param temperature
     * @param humidity
     * @param pressure
     */
    public void update(float temperature, float humidity, float pressure, String wind, String msg) {
        this.temperature = temperature;
        this.humidity = humidity;
        this.msg = msg;
        display();
    }
}
